#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

use std::os::raw::c_char;
use std::ffi::CStr;

pub mod demoutils;

#[no_mangle]
pub extern fn basic_integer(value : i32) -> i32 {
    let result : i32 = demoutils::data_type::datatype_scalar_i32(value);
    return result;
}

#[no_mangle]
pub extern fn basic_uinteger(value : u32) -> u32 {
    let result = demoutils::data_type::datatype_scalar_u32(value);
    return result;
}

#[no_mangle]
pub extern fn basic_float(value : f32) -> f32 {
    let result = demoutils::data_type::datatype_scalar_f32(value);
    return result;
}

#[no_mangle]
pub extern fn basic_doube(value : f64) -> f64 {
    let result = demoutils::data_type::datatype_scalar_f64(value);
    return result;
}

#[no_mangle]
pub fn basic_bool(value : bool) -> bool {
    let result = demoutils::data_type::datatype_bool(value);
    return result;
}

#[no_mangle]
pub fn basic_str(value : * const c_char) -> *const c_char {
    let input : &str;
    unsafe {
        input = CStr::from_ptr(value).to_str().expect("");
    }

    let mut output = demoutils::data_type::basic_str(input.to_string());
    output.push_str("\0");
    let result = output.as_str().as_ptr();
    return result as *const c_char;
}

// compound types
#[no_mangle]
pub fn array_12345() -> [i32; 5] {
    let result = demoutils::compound_type::array_12345();
    return result;
}

#[no_mangle]
pub fn array_months() -> [&'static str; 12] {
    let result = demoutils::compound_type::array_months();
    return result;
}